package com.wangchao.administrator.zenmechi.ui.detailactivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wangchao.administrator.zenmechi.R;
import com.wangchao.administrator.zenmechi.base.BaseActivity;
import com.wangchao.administrator.zenmechi.bean.goodsdetail.GoodsDetail;
import com.wangchao.administrator.zenmechi.bean.goodsdetail.ResultBean;
import com.wangchao.administrator.zenmechi.config.UrlConfig;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by My on 2016/10/19.
 */
public class DetailActivity extends BaseActivity implements DetailContract.View {

    @BindView(R.id.iv_back_detail)
    ImageView ivBackDetail;
    @BindView(R.id.tv_title_detail)
    TextView tvTitleDetail;
    @BindView(R.id.tv_share_detail)
    TextView tvShareDetail;
    @BindView(R.id.rela_top_detail)
    RelativeLayout relaTopDetail;
    @BindView(R.id.tv_intoshop_detail)
    TextView tvIntoshopDetail;
    @BindView(R.id.tv_intomarket_detail)
    TextView tvIntomarketDetail;
    @BindView(R.id.ll_bottom_detail)
    LinearLayout llBottomDetail;
    @BindView(R.id.iv_top_detail)
    ImageView ivTopDetail;
    @BindView(R.id.tv_name_detail)
    TextView tvNameDetail;
    @BindView(R.id.tv_truepri_detail)
    TextView tvTruepriDetail;
    @BindView(R.id.tv_truepriunit_detail)
    TextView tvTruepriunitDetail;
    @BindView(R.id.iv_add_detail)
    ImageView ivAddDetail;
    @BindView(R.id.tv_marpri_detail)
    TextView tvMarpriDetail;
    @BindView(R.id.tv_counts_detail)
    TextView tvCountsDetail;
    @BindView(R.id.iv_minus_detail)
    ImageView ivMinusDetail;
    @BindView(R.id.rela_name_detail)
    RelativeLayout relaNameDetail;
    @BindView(R.id.iv_market_detail)
    ImageView ivMarketDetail;
    @BindView(R.id.tv_marketname_detail)
    TextView tvMarketnameDetail;
    @BindView(R.id.tv_marketlastname_detail)
    TextView tvMarketlastnameDetail;
    @BindView(R.id.tv_onsaling_detail)
    TextView tvOnsalingDetail;
    @BindView(R.id.tv_saled_detail)
    TextView tvSaledDetail;
    @BindView(R.id.rela_marketname_detail)
    RelativeLayout relaMarketnameDetail;
    @BindView(R.id.tv_comment_detail)
    TextView tvCommentDetail;
    @BindView(R.id.iv_comment_detail)
    ImageView ivCommentDetail;
    @BindView(R.id.rela_commnet_detail)
    RelativeLayout relaCommnetDetail;
    @BindView(R.id.tv_introduce_detail)
    TextView tvIntroduceDetail;
    @BindView(R.id.iv_div_detail)
    ImageView ivDivDetail;
    @BindView(R.id.tv_introconnent_detail)
    TextView tvIntroconnentDetail;
    @BindView(R.id.rela_introduce_detail)
    LinearLayout relaIntroduceDetail;
    @BindView(R.id.ll_body_detail)
    LinearLayout llBodyDetail;
    @BindView(R.id.rela_out_sv)
    RelativeLayout relaOutSv;
    private DetailContract.Presenter presenter;

    @Override
    public void initViews() {

    }

    @Override
    public void initData() {
       String id= getIntent().getStringExtra("id");
        Log.i("bbb",id);
        presenter=new DetailPresenter(this);
//        anfou-api/goods/detail/3506?access_token=defaultValue
        Map<String,String> stringMap=new HashMap<>();
        stringMap.put(UrlConfig.Params.ACCESS_TOKEN,UrlConfig.DefaultVaule.ACCESS_TOKEN);
        presenter.getNetworkDate("3506",stringMap);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_detail;
    }

    @Override
    public void onSuccess(GoodsDetail goodsDetail) {
        Log.i("bbb","suv");
        if (goodsDetail!=null)
        fillingdate(goodsDetail);

    }

    private void fillingdate(GoodsDetail goodsDetail) {
        ResultBean reuslt=goodsDetail.getResult();
        if (reuslt!=null&&reuslt.getDetail_pic()!=null)
        presenter.loadingInmage(ivTopDetail,this,goodsDetail.getResult().getDetail_pic());
    }

    @Override
    public void onFail(Exception e) {
        Log.i("bbb","fav");
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.iv_back_detail, R.id.tv_share_detail, R.id.tv_intoshop_detail, R.id.tv_intomarket_detail, R.id.iv_add_detail, R.id.iv_minus_detail, R.id.rela_marketname_detail, R.id.rela_commnet_detail})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back_detail:
                finish();
                break;
            case R.id.tv_share_detail:
                break;
            case R.id.tv_intoshop_detail:
                break;
            case R.id.tv_intomarket_detail:
                break;
            case R.id.iv_add_detail:

                break;
            case R.id.iv_minus_detail:
                break;
            case R.id.rela_marketname_detail:
                break;
            case R.id.rela_commnet_detail:
                break;
        }
    }
}
